package com.unism.data.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.unism.data.dao.InstanceDao;
import com.unism.entity.INInstance;
import com.unism.util.ResponseByJson;

@Service("datainstanceService")
public class InstanceService  {

	@Autowired
	private InstanceDao instanceDao;

	public ResponseByJson add(){
		INInstance is=new INInstance();
		is.setDeviceType(123456);
		is.setId("00236b78-436e-4d79-a23d-f56da7ea06b4");
		Integer ins=instanceDao.insert(is);
    	ResponseByJson result= new ResponseByJson();
    	result.setResult(ins);
    	return result;
    }
	public ResponseByJson deleteById(){
		Integer ins=instanceDao.deleteById("00236b78-436e-4d79-a23d-f56da7ea06b4");
    	ResponseByJson result= new ResponseByJson();
    	result.setResult(ins);
    	return result;
    }
	
	public ResponseByJson update(){
		INInstance is=new INInstance();
		is.setId("00236b78-436e-4d79-a23d-f56da7ea06b4");
		is.setDeviceId(12345L);
		Integer ins=instanceDao.updateAllColumnById(is);
    	ResponseByJson result= new ResponseByJson();
    	result.setResult(ins);
    	return result;
    }
	public ResponseByJson select(){
		INInstance ins=instanceDao.selectById("00236b78-436e-4d79-a23d-f56da7ea06b4");
    	ResponseByJson result= new ResponseByJson();
    	result.setResult(ins);
    	return result;
    }
	public ResponseByJson select1(){
		List<INInstance> ins=instanceDao.selectList(
		        new EntityWrapper<INInstance>().eq("deviceType",3)
				);
    	ResponseByJson result= new ResponseByJson();
    	result.setResult(ins);
    	return result;
    }
	public ResponseByJson select2(){
		List<INInstance> ins = instanceDao.selectPage(
		        new Page<INInstance>(3, 1),
		        new EntityWrapper<INInstance>().eq("deviceType",3)
		);
    	ResponseByJson result= new ResponseByJson();
    	result.setResult(ins);
    	return result;
    }
	public InstanceDao getInstanceDao() {
		return instanceDao;
	}
	public void setInstanceDao(InstanceDao instanceDao) {
		this.instanceDao = instanceDao;
	}
}
